package com.englisheveryday.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.englisheveryday.dao.FeedbackDAO;
import com.englisheveryday.dao.SystemUpdateDAO;
import com.englisheveryday.response.SystemUpdateResponse;
import com.englisheveryday.vo.FeedBackVO;
import com.englisheveryday.vo.SystemUpdateVO;

/**
 * <pre>
 *    
 * </pre>
 * @author 马永华
 * @date 2012-9-16 上午11:00:11
 * @version 1.1
 */
@Service
public class SystemService {

	private FeedbackDAO feedBackDAO;
	private SystemUpdateDAO systemUpdateDAO;
	@Autowired
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate){
		feedBackDAO = new FeedbackDAO(jdbcTemplate);
		systemUpdateDAO = new SystemUpdateDAO(jdbcTemplate);
	}
	
	
	//保存用户留言
	@Transactional(rollbackFor={Exception.class,RuntimeException.class})
	public int save_feedBack(String content){
		return feedBackDAO.save(content);
	}
	
	//查询系统更新
	public SystemUpdateResponse get_systemUpdate(){
		return systemUpdateDAO.get_systemUpdate();
	}
	//查询所有系统更新
	public List<SystemUpdateVO> query_systemUpdate(int page,int count){
		return systemUpdateDAO.query_systemUpdate(page, count);
	}
 	
	//查询用户反馈
	public List<FeedBackVO> query_feedback(int page,int count){
		return feedBackDAO.query(page, count);
	}
	
	//删除用户反馈
	@Transactional(rollbackFor={Exception.class,RuntimeException.class})
	public int delete_feedback(String id){
		return feedBackDAO.delete_Feedback(id);
	}
	
	//添加新版本
	@Transactional(rollbackFor={Exception.class,RuntimeException.class})
	public int save_systemupdate(int nowversion,String url){
		return systemUpdateDAO.save_systemUpdate(nowversion, url);
	}
	//删除新版本
	@Transactional(rollbackFor={Exception.class,RuntimeException.class})
	public int delete_systemupdate(String id){
		return systemUpdateDAO.delete_systemupdate(id);
	}
}

